* GSS analysis for: 
* Unions, Class Identification and Policy Attitudes
* Date: 03/31/22


*******************************************************************************
***** Subjective class analysis.
*******************************************************************************


* Models.
* 4 cat. subjective class.
mlogit subcls i.objcls5 i.union i.working i.female age age2 i.race pid7 i.region4 i.year
estimates store scls_ML

mlogit subcls i.objcls5 i.union i.working i.female age age2 i.race pid7 i.region4 i.year i.objcls5#i.union
estimates store scls_objXuni_ML

* 2 cat. subjective class. Working class = 1, others = 0.
logit subcls_2 i.objcls5 i.union i.working i.female age age2 i.race pid7 i.region4 i.year
estimates store scls_WC

logit subcls_2 i.objcls5 i.union i.working i.female age age2 i.race pid7 i.region4 i.year i.objcls5#i.union
estimates store scls_objXuni_WC



* Effects.

* Interaction effects, no calculation for first differences.
* Logit model.
estimates restore scls_objXuni_WC
margins objcls5#union , saving(pr_objXuni_WC.dta, replace) 

* Multinomial model.
estimates restore scls_objXuni_ML
margins objcls5#union , saving(pr_objXuni_ML.dta, replace) 


* Additive effects.
estimates restore scls_ML
margins objcls5 union , saving(pr_scls.dta, replace)

* Recode some names in saved results.
preserve
use pr_scls.dta, clear
clonevar var = _m1
replace var = 6 if _m2 == 0
replace var = 7 if _m2 == 1
gen str10 vlab = ""
replace vlab = "Obj. lower" if var == 1
replace vlab = "Obj. working" if var == 2
replace vlab = "Obj. lower mid." if var == 3
replace vlab = "Obj. upper mid." if var == 4
replace vlab = "Obj. upper" if var == 5
replace vlab = "Non union" if var == 6
replace vlab = "Union" if var == 7
save pr_scls.dta, replace
restore




* Matching.

capture drop cem_*

*imb subcls_2 edu5 female age white region4 year if union!=. , treatment(union)

cem edu5 (#0) female (#0) age (25 35 45 55 65 75 85) white (#0) region4 (#0) year (1975.5 1978.5 1983.5 1985.5 1987.5 1989.5 1991.5 1994.5 1998.5 2002.5 2006.5 2010.5 2014.5) if union!=. , treatment(union) showbreaks 


* Models.
* 4 cat. subjective class.
mlogit subcls i.objcls5 i.union i.female age age2 i.race pid7 i.working i.region4 i.year [iweight=cem_weights]
estimates store scls_ML_cem

mlogit subcls i.objcls5 i.union i.female age age2 i.race pid7 i.working i.region4 i.year i.objcls5#i.union [iweight=cem_weights]
estimates store scls_objXuni_ML_cem

